﻿using System;
using System.Collections.Generic;
using System.Linq;
using Puerts;

namespace Vasuleg.Editor.Setting
{
    [Configure]
    public class PuertsBindingConfig
    {
        [Binding]
        public static IEnumerable<Type> Bindings => ParsingBindingType(new[]
        {
            typeof(UnityEngine.Debug),
            typeof(UnityEngine.Vector3),
            typeof(UnityEngine.GameObject),
            typeof(UnityEngine.Transform),
            typeof(UnityEngine.Component),
        }).Distinct();

        private static IEnumerable<Type> ParsingBindingType(IEnumerable<Type> typeArray)
        {
            foreach (var type in typeArray)
            {
                yield return type;
                var baseType = type.BaseType;
                while (baseType != null)
                {
                    yield return baseType;
                    baseType = baseType.BaseType;
                }
            }
        }
    }
}